package com.cartoon.config;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cartoon.controller"))//controller层路径
                .paths(PathSelectors.any())
                .build()
                .apiInfo(webApiInfo());
    }

    private ApiInfo webApiInfo(){

        return new ApiInfoBuilder()
                .title("cartoonAPI")
                .description("漫画app")
                .version("1.0")
                .contact(new Contact("Helen", "网站首页网址", "3123314409@qq.com"))
                .build();
    }
}
